﻿Public Partial Class frm_Valorizacion
    Inherits System.Web.UI.Page
    Dim iNroCarga As Integer
    Dim iAnno As Integer
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not IsPostBack Then
            Me.txtIDSeguro.Text = Request("IDSeguro")
            ObtieneDatosTMP()
            'iAnno = Request("iAnno")

            Obtener_Planes()
        End If
    End Sub


    Private Sub Obtener_Planes()
        Dim exec As New BusinessCatastrofico.TMP_VentaSeguro
        Dim rp As New NetResponse.MsSqlServer

        exec._iAnno = iAnno
        exec.Get_Planes(rp)
        grPlanes.DataSource = Nothing
        If rp.TieneDatos Then
            grPlanes.DataSource = rp.Ds
            grPlanes.DataBind()
        End If
        If rp.Errores Then

        End If
        rp.Dispose()
        exec.Dispose()
    End Sub
    Private Sub ObtieneDatosTMP()
        Dim exec As New BusinessCatastrofico.TMP_VentaSeguro
        Dim rp As New NetResponse.MsSqlServer
        exec._IDSeguro = txtIDSeguro.Text
        exec.Get_TMP_VentaSeguro(rp)
        If rp.TieneDatos Then

            iAnno = rp.Ds.Tables(0).Rows(0).Item("AnnoAsegurado")

        End If
        If rp.Errores Then
        End If
        rp.Dispose()
        exec.Dispose()
    End Sub
 
    Protected Sub btIngresar_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btIngresar.Click
        If grPlanes.SelectedIndex < 0 Then
            Anthem.Manager.AddScriptForClientSideEval("alert('Debe Seleccionar Plan');")
            Exit Sub
        End If

        ' Dim iNroCarga As Integer
        Dim szPlan As String
        iNroCarga = grPlanes.SelectedItem.Cells(1).Text.Replace("&nbsp;", "")
        szPlan = grPlanes.SelectedItem.Cells(2).Text.Replace("&nbsp;", "")

        Dim exec As New BusinessCatastrofico.TMP_VentaSeguro
        Dim rp As New NetResponse.MsSqlServer

        exec._IDSeguro = txtIDSeguro.Text
        exec._NroCarga = iNroCarga
        exec._Plan = szPlan
        exec.UPD_NroCarga_TMP(rp)

        If rp.TieneDatos Then
        End If
        If rp.Errores Then

        End If
        rp.Dispose()
        exec.Dispose()

        Dim szURL As String
        szURL = "frm_IngresoDatos.aspx?IDSeguro=" & txtIDSeguro.Text & "&Carga=" & iNroCarga.ToString
        Response.Redirect(szURL)

    End Sub

 
    Protected Sub btVolver_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btVolver.Click
        Dim szURL As String
        szURL = "frm_DatosSimulacion.aspx" '& txtIDSeguro.Text
        Response.Redirect(szURL)

    End Sub
End Class